<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 
        1、父  position: relative; 子： position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
        2、父  position: relative; 子： position: absolute; left: 50%; top: 50%; margin-top: -50px; margin-left: -50px;
        3、父  display: flex; justify-content:center; align-items:center;


    -->
    <div class="father">
        <div class="son">123456</div>
    </div>
</body>
<style>
    /* .father {
        position: relative;
        width:300px;
        height:400px;
        background: lightseagreen;
    } */

    /* .son {  ----1
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%,-50%);
    } */

    /* .son {
        position: absolute;
        top: 50%;
        left: 50%;
        margin-top: -50px; 
        margin-left: -50px;
    } */

    .father {
        display: flex; 
        justify-content:center; 
        align-items:center;
        width:300px;
        height:400px;
        background: lightseagreen;
    }
</style>
</html>